#include "Constant.h"

enum INDEX_MAP_TYPE {INDEX, MAXIMUM};
enum DENSITY_MAP_TYPE {SIZE, CLUSTER, DENSITY, FREQ, MAX, HOR, VER};

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <stdlib.h>

//-----------------------------------------------------------------------------
// GrNode Class
//-----------------------------------------------------------------------------
class CGrNode
{
public:
	
	int m_count;
	double m_density;
	double m_size;
	double m_cluster;
	double m_freq;
	CGrNode* m_nextNode;

	CGrNode();
	~CGrNode();


protected:

};

//-----------------------------------------------------------------------------
// Map Class
//-----------------------------------------------------------------------------

class CMap
{
public:

	int m_height, m_width;
	int m_grPixels;
	int m_maxPixels;
	int m_grNum;
	char m_mapName[256], m_fileName[256];
	
	CGrNode** grainList;
	
	DENSITYMAP m_densityMap[MAXNUMDENSITYMAP];
	INDEXMAP m_indexMap[MAXNUMINDEXMAP];
	
	CMap();
	CMap(int* mapHeight, int* mapWidth);	
	~CMap();
	
	char* GetMapName();
	char* GetFileName();
	int GetHeight();
	int GetWidth();
	int GetGrainAmount();
	int GetGrainPixels();
	int GetMaxPixels();
	
	INDEXMAP MakeIndexMap();

	INDEXMAP MakeNULLIndexMap();
	DENSITYMAP MakeNULLDensityMap();
	void DeleteIndexMap(INDEXMAP map);
	void DeleteDensityMap(DENSITYMAP map);

	INDEXMAP MakeMaxCircleMap();
	
	INDEXMAP IndexMapType(int mapType, char* strMapType);
	DENSITYMAP DensityMapType(int apType, char* strMapType);

	double Average(int mapType);
	double NullAverage(int mapType);
	double PhaseAverage(int mapType);
	double StandardDev(int mapType);
	double PositiveStandardDev(int mapType);
	double NegativeStandardDev(int mapType);
	double Fraction();
	double FindMaxDensity(int mapType);
	double FindMinDensity(int mapType);

	void PrintASCIIMap(int mapType);
	void PrintGrASCIIMap(int mapType);
	void PrintGrainList();
	void PrintList(int mapType);
	void Print2DList(int mapType);
	void PrintFreq();

protected:
	
};

